import { _decorator, Component, Node } from 'cc';
import { LifeCycleReactive } from './LifeCycleReactive';
import { LogWithTag, LogWithTagInnerData } from './LogWithTag';
import { ReactiveProperty } from './ReactiveProperty';
import { Subscription } from 'rxjs';
import { Color } from 'cc';
import { applyMixins } from '../../utils/applyMixins';
const { ccclass, property } = _decorator;

@ccclass('LifeAndLog')
export class LifeAndLog implements LifeCycleReactive, LogWithTag {

    timestamp: number = 0;

    willBind() { }
    onInitManager() { }
    onDestroyManager() { }

    constructor() {
        this.timestamp = Date.now();
    }

    init() {
        this.logInit();
        this.willBind();
        this.bind();
        this.onInitManager();
    }

    destroy() {
        this.onDestroyManager();
        this.unbind();
    }

    // Implement delegates

    // LifeCycleReactive
    binded = ReactiveProperty.Create(false);
    bind() { }
    unbind() { }
    manualBind(list: (Subscription | (() => Subscription))[]): void { }
    _mainSubscription?: Subscription;
    getMainSubscription(): Subscription { return this._mainSubscription; }
    _extraManagedSubscriptions?: Record<string, Subscription> = {};
    getExtraManagedSubscriptions(): Record<string, Subscription> { return null; }
    resetSubscriptions(key: string, genSubscription: () => Subscription): void { };

    // LogWithTag delegate
    _lwt = {} as LogWithTagInnerData;
    get logEnable(): boolean { return }
    get logColorOverride(): Color { return }
    logInit() { }
    debug(...param: any[]) { }
    log(...param: any[]) { }
    warn(...param: any[]) { }
    error(...param: any[]) { }

}

applyMixins(LifeAndLog, [LifeCycleReactive, LogWithTag]);